﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace NotificationServer.DataAccessLayer.DAO
{
    public class NotificationDAO
    {
        private DbAccess _dbAccess;

        public NotificationDAO()
        {
            _dbAccess = new DbAccess();
        }

        public bool RegisterNotification(Guid notificationId, Guid deviceId, string notification)
        {
            string query = string.Format("INSERT INTO Notification(id, device_id, text) VALUES(@id, @device_id, @text)");
            SqlParameter[] sqlParams = new SqlParameter[3];
            sqlParams[0] = new SqlParameter("@id", SqlDbType.UniqueIdentifier);
            sqlParams[0].Value = notificationId;
            sqlParams[1] = new SqlParameter("@device_id", SqlDbType.UniqueIdentifier);
            sqlParams[1].Value = deviceId;
            sqlParams[2] = new SqlParameter("@text", SqlDbType.NVarChar);
            sqlParams[2].Value = notification;            

            return _dbAccess.InsertQuery(query, sqlParams);
        }
    }
}
